package com.flymobi.service;

import java.util.List;

import com.flymobi.fw.modules.CommonService;
import com.flymobi.fw.util.IpUtil;
import com.flymobi.po.IpLocation;
import com.flymobi.util.QL;

public class IpLocationService extends CommonService {

	public List<IpLocation> list(int startRow, int pagePerSize) {
		return dao.find(IpLocation.class, QL.HQL.IpLocation.LIST, new Object[] {},startRow, pagePerSize);
	}
	
	public List<IpLocation> listNullLocal(int startRow, int pagePerSize) {
		return dao.find(IpLocation.class, QL.HQL.IpLocation.LIST_NULL_LOCAL, new Object[] {},startRow, pagePerSize);
	}
	
	public IpLocation find(String ip){
		IpLocation ipLoc=null;
		Long ipValue=IpUtil.ipToValue(ip);
		ipLoc=dao.findSingle(IpLocation.class,  QL.HQL.IpLocation.FIND_BY_IP, new Object[] {ipValue,ipValue});
		return ipLoc;
	}
	
	public Long getCount() {
		return dao.getCount(QL.HQL.IpLocation.GET_COUNT, new Object[] {});
	}

	public void save(IpLocation IpLocation) {
		dao.save(IpLocation);
	}

	public IpLocation load(String id) {
		return dao.load(IpLocation.class, new Long(id));
	}
	
	public IpLocation get(String id) {
		return dao.get(IpLocation.class, new Long(id));
	}

	public void delete(String id) {
		dao.delete(this.get(id));
	}
}
